<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Userswithdrawals extends Model
{
    protected $table = 'users_withdrawals';
    protected $primaryKey = 'id';

    public static function addUsersWithdrawals($users_id,$alipay,$name,$money)
    {
        return self::insertGetId([
            'users_id'   => $users_id,
            'alipay'      => $alipay,
            'name'   => $name,
            'money'   => $money,
            'created_at' => time(),
        ]);
    }

    public static function getUsersWithdrawalLists($users_id,$limit=20)
    {
        return self::where("users_id",$users_id)->orderBy('id', 'desc')->paginate($limit);
    }

    public static function getWithdrawalLists($status)
    {
        return self::where("status",$status)->orderBy('id', 'desc')->paginate(25);
    }

    public static function updateUsersWithdrawalsStatus($id,$status)
    {
        return self::where("id",$id)->update(["status"=>$status]);
    }
}
